class PositionTool
    # 监听工具被启用
    def activate
      # 屏幕坐标
      @scr_pt = nil 
      # 模型坐标
      @pick_pt = nil 
      # 光标位置
      @mouse_ip = Sketchup::InputPoint.new
    end
    
    # 监听工具被停用
    def deactivate(view)
      # 将视图标记为需要重绘
      view.invalidate
    end

    # 监听鼠标移动
  def onMouseMove(flags, x, y, view)
    @scr_pt = Geom::Point3d.new(x, y, 0)
    @mouse_ip.pick(view, x, y)
    @pick_pt = @mouse_ip.position
    # 将视图标记为需要重绘
    view.invalidate
  end
    # 监听刷新视图以允许工具进行绘图
  def draw(view)
    @mouse_ip.draw(view) if @mouse_ip.valid?
    return unless @scr_pt && @pick_pt
    draw_pos = @scr_pt.offset(X_AXIS, 20)
    view.draw_text(draw_pos, @pick_pt.to_s, color: 'orange', :size => 24)
  end


    # ...
end



my_tool = PositionTool.new()
Sketchup.active_model.select_tool(my_tool)